<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>LCOV - code analysis - include/caffe/data_transformer.hpp</title>
  <link rel="stylesheet" type="text/css" href="../../gcov.css">
</head>

<body>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="title">LCOV - code coverage report</td></tr>
    <tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>

    <tr>
      <td width="100%">
        <table cellpadding=1 border=0 width="100%">
          <tr>
            <td width="10%" class="headerItem">Current view:</td>
            <td width="35%" class="headerValue"><a href="../../index.html">top level</a> - <a href="index.html">include/caffe</a> - data_transformer.hpp<span style="font-size: 80%;"> (source / <a href="data_transformer.hpp.func-sort-c.html">functions</a>)</span></td>
            <td width="5%"></td>
            <td width="15%"></td>
            <td width="10%" class="headerCovTableHead">Hit</td>
            <td width="10%" class="headerCovTableHead">Total</td>
            <td width="15%" class="headerCovTableHead">Coverage</td>
          </tr>
          <tr>
            <td class="headerItem">Test:</td>
            <td class="headerValue">code analysis</td>
            <td></td>
            <td class="headerItem">Lines:</td>
            <td class="headerCovTableEntry">1</td>
            <td class="headerCovTableEntry">1</td>
            <td class="headerCovTableEntryHi">100.0 %</td>
          </tr>
          <tr>
            <td class="headerItem">Date:</td>
            <td class="headerValue">2020-09-11 22:50:33</td>
            <td></td>
            <td class="headerItem">Functions:</td>
            <td class="headerCovTableEntry">2</td>
            <td class="headerCovTableEntry">4</td>
            <td class="headerCovTableEntryLo">50.0 %</td>
          </tr>
          <tr>
            <td class="headerItem">Legend:</td>
            <td class="headerValueLeg">            Lines:
            <span class="coverLegendCov">hit</span>
            <span class="coverLegendNoCov">not hit</span>
</td>
            <td></td>
          </tr>
          <tr><td><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
        </table>
      </td>
    </tr>

    <tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
  </table>

  <table cellpadding=0 cellspacing=0 border=0>
    <tr>
      <td><br></td>
    </tr>
    <tr>
      <td>
<pre class="sourceHeading">          Line data    Source code</pre>
<pre class="source">
<a name="1"><span class="lineNum">       1 </span>            : #ifndef CAFFE_DATA_TRANSFORMER_HPP</a>
<span class="lineNum">       2 </span>            : #define CAFFE_DATA_TRANSFORMER_HPP
<span class="lineNum">       3 </span>            : 
<span class="lineNum">       4 </span>            : #include &lt;vector&gt;
<span class="lineNum">       5 </span>            : 
<span class="lineNum">       6 </span>            : #include &quot;caffe/blob.hpp&quot;
<span class="lineNum">       7 </span>            : #include &quot;caffe/common.hpp&quot;
<span class="lineNum">       8 </span>            : #include &quot;caffe/proto/caffe.pb.h&quot;
<span class="lineNum">       9 </span>            : 
<span class="lineNum">      10 </span>            : namespace caffe {
<span class="lineNum">      11 </span>            : 
<span class="lineNum">      12 </span>            : /**
<span class="lineNum">      13 </span>            :  * @brief Applies common transformations to the input data, such as
<span class="lineNum">      14 </span>            :  * scaling, mirroring, substracting the image mean...
<span class="lineNum">      15 </span>            :  */
<span class="lineNum">      16 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">      17 </span>            : class DataTransformer {
<a name="18"><span class="lineNum">      18 </span>            :  public:</a>
<span class="lineNum">      19 </span>            :   explicit DataTransformer(const TransformationParameter&amp; param, Phase phase);
<span class="lineNum">      20 </span><span class="lineCov">          8 :   virtual ~DataTransformer() {}</span>
<span class="lineNum">      21 </span>            : 
<span class="lineNum">      22 </span>            :   /**
<span class="lineNum">      23 </span>            :    * @brief Initialize the Random number generations if needed by the
<span class="lineNum">      24 </span>            :    *    transformation.
<span class="lineNum">      25 </span>            :    */
<span class="lineNum">      26 </span>            :   void InitRand();
<span class="lineNum">      27 </span>            : 
<span class="lineNum">      28 </span>            :   /**
<span class="lineNum">      29 </span>            :    * @brief Applies the transformation defined in the data layer's
<span class="lineNum">      30 </span>            :    * transform_param block to the data.
<span class="lineNum">      31 </span>            :    *
<span class="lineNum">      32 </span>            :    * @param datum
<span class="lineNum">      33 </span>            :    *    Datum containing the data to be transformed.
<span class="lineNum">      34 </span>            :    * @param transformed_blob
<span class="lineNum">      35 </span>            :    *    This is destination blob. It can be part of top blob's data if
<span class="lineNum">      36 </span>            :    *    set_cpu_data() is used. See data_layer.cpp for an example.
<span class="lineNum">      37 </span>            :    */
<span class="lineNum">      38 </span>            :   void Transform(const Datum&amp; datum, Blob&lt;Dtype&gt;* transformed_blob);
<span class="lineNum">      39 </span>            : 
<span class="lineNum">      40 </span>            :   /**
<span class="lineNum">      41 </span>            :    * @brief Applies the transformation defined in the data layer's
<span class="lineNum">      42 </span>            :    * transform_param block to a vector of Datum.
<span class="lineNum">      43 </span>            :    *
<span class="lineNum">      44 </span>            :    * @param datum_vector
<span class="lineNum">      45 </span>            :    *    A vector of Datum containing the data to be transformed.
<span class="lineNum">      46 </span>            :    * @param transformed_blob
<span class="lineNum">      47 </span>            :    *    This is destination blob. It can be part of top blob's data if
<span class="lineNum">      48 </span>            :    *    set_cpu_data() is used. See memory_layer.cpp for an example.
<span class="lineNum">      49 </span>            :    */
<span class="lineNum">      50 </span>            :   void Transform(const vector&lt;Datum&gt; &amp; datum_vector,
<span class="lineNum">      51 </span>            :                 Blob&lt;Dtype&gt;* transformed_blob);
<span class="lineNum">      52 </span>            : 
<span class="lineNum">      53 </span>            : #ifdef USE_OPENCV
<span class="lineNum">      54 </span>            :   /**
<span class="lineNum">      55 </span>            :    * @brief Applies the transformation defined in the data layer's
<span class="lineNum">      56 </span>            :    * transform_param block to a vector of Mat.
<span class="lineNum">      57 </span>            :    *
<span class="lineNum">      58 </span>            :    * @param mat_vector
<span class="lineNum">      59 </span>            :    *    A vector of Mat containing the data to be transformed.
<span class="lineNum">      60 </span>            :    * @param transformed_blob
<span class="lineNum">      61 </span>            :    *    This is destination blob. It can be part of top blob's data if
<span class="lineNum">      62 </span>            :    *    set_cpu_data() is used. See memory_layer.cpp for an example.
<span class="lineNum">      63 </span>            :    */
<span class="lineNum">      64 </span>            :   void Transform(const vector&lt;cv::Mat&gt; &amp; mat_vector,
<span class="lineNum">      65 </span>            :                 Blob&lt;Dtype&gt;* transformed_blob);
<span class="lineNum">      66 </span>            : 
<span class="lineNum">      67 </span>            :   /**
<span class="lineNum">      68 </span>            :    * @brief Applies the transformation defined in the data layer's
<span class="lineNum">      69 </span>            :    * transform_param block to a cv::Mat
<span class="lineNum">      70 </span>            :    *
<span class="lineNum">      71 </span>            :    * @param cv_img
<span class="lineNum">      72 </span>            :    *    cv::Mat containing the data to be transformed.
<span class="lineNum">      73 </span>            :    * @param transformed_blob
<span class="lineNum">      74 </span>            :    *    This is destination blob. It can be part of top blob's data if
<span class="lineNum">      75 </span>            :    *    set_cpu_data() is used. See image_data_layer.cpp for an example.
<span class="lineNum">      76 </span>            :    */
<span class="lineNum">      77 </span>            :   void Transform(const cv::Mat&amp; cv_img, Blob&lt;Dtype&gt;* transformed_blob);
<span class="lineNum">      78 </span>            : #endif  // USE_OPENCV
<span class="lineNum">      79 </span>            : 
<span class="lineNum">      80 </span>            :   /**
<span class="lineNum">      81 </span>            :    * @brief Applies the same transformation defined in the data layer's
<span class="lineNum">      82 </span>            :    * transform_param block to all the num images in a input_blob.
<span class="lineNum">      83 </span>            :    *
<span class="lineNum">      84 </span>            :    * @param input_blob
<span class="lineNum">      85 </span>            :    *    A Blob containing the data to be transformed. It applies the same
<span class="lineNum">      86 </span>            :    *    transformation to all the num images in the blob.
<span class="lineNum">      87 </span>            :    * @param transformed_blob
<span class="lineNum">      88 </span>            :    *    This is destination blob, it will contain as many images as the
<span class="lineNum">      89 </span>            :    *    input blob. It can be part of top blob's data.
<span class="lineNum">      90 </span>            :    */
<span class="lineNum">      91 </span>            :   void Transform(Blob&lt;Dtype&gt;* input_blob, Blob&lt;Dtype&gt;* transformed_blob);
<span class="lineNum">      92 </span>            : 
<span class="lineNum">      93 </span>            :   /**
<span class="lineNum">      94 </span>            :    * @brief Infers the shape of transformed_blob will have when
<span class="lineNum">      95 </span>            :    *    the transformation is applied to the data.
<span class="lineNum">      96 </span>            :    *
<span class="lineNum">      97 </span>            :    * @param datum
<span class="lineNum">      98 </span>            :    *    Datum containing the data to be transformed.
<span class="lineNum">      99 </span>            :    */
<span class="lineNum">     100 </span>            :   vector&lt;int&gt; InferBlobShape(const Datum&amp; datum);
<span class="lineNum">     101 </span>            :   /**
<span class="lineNum">     102 </span>            :    * @brief Infers the shape of transformed_blob will have when
<span class="lineNum">     103 </span>            :    *    the transformation is applied to the data.
<span class="lineNum">     104 </span>            :    *    It uses the first element to infer the shape of the blob.
<span class="lineNum">     105 </span>            :    *
<span class="lineNum">     106 </span>            :    * @param datum_vector
<span class="lineNum">     107 </span>            :    *    A vector of Datum containing the data to be transformed.
<span class="lineNum">     108 </span>            :    */
<span class="lineNum">     109 </span>            :   vector&lt;int&gt; InferBlobShape(const vector&lt;Datum&gt; &amp; datum_vector);
<span class="lineNum">     110 </span>            :   /**
<span class="lineNum">     111 </span>            :    * @brief Infers the shape of transformed_blob will have when
<span class="lineNum">     112 </span>            :    *    the transformation is applied to the data.
<span class="lineNum">     113 </span>            :    *    It uses the first element to infer the shape of the blob.
<span class="lineNum">     114 </span>            :    *
<span class="lineNum">     115 </span>            :    * @param mat_vector
<span class="lineNum">     116 </span>            :    *    A vector of Mat containing the data to be transformed.
<span class="lineNum">     117 </span>            :    */
<span class="lineNum">     118 </span>            : #ifdef USE_OPENCV
<span class="lineNum">     119 </span>            :   vector&lt;int&gt; InferBlobShape(const vector&lt;cv::Mat&gt; &amp; mat_vector);
<span class="lineNum">     120 </span>            :   /**
<span class="lineNum">     121 </span>            :    * @brief Infers the shape of transformed_blob will have when
<span class="lineNum">     122 </span>            :    *    the transformation is applied to the data.
<span class="lineNum">     123 </span>            :    *
<span class="lineNum">     124 </span>            :    * @param cv_img
<span class="lineNum">     125 </span>            :    *    cv::Mat containing the data to be transformed.
<span class="lineNum">     126 </span>            :    */
<span class="lineNum">     127 </span>            :   vector&lt;int&gt; InferBlobShape(const cv::Mat&amp; cv_img);
<span class="lineNum">     128 </span>            : #endif  // USE_OPENCV
<span class="lineNum">     129 </span>            : 
<span class="lineNum">     130 </span>            :  protected:
<span class="lineNum">     131 </span>            :    /**
<span class="lineNum">     132 </span>            :    * @brief Generates a random integer from Uniform({0, 1, ..., n-1}).
<span class="lineNum">     133 </span>            :    *
<span class="lineNum">     134 </span>            :    * @param n
<span class="lineNum">     135 </span>            :    *    The upperbound (exclusive) value of the random number.
<span class="lineNum">     136 </span>            :    * @return
<span class="lineNum">     137 </span>            :    *    A uniformly random integer value from ({0, 1, ..., n-1}).
<span class="lineNum">     138 </span>            :    */
<span class="lineNum">     139 </span>            :   virtual int Rand(int n);
<span class="lineNum">     140 </span>            : 
<span class="lineNum">     141 </span>            :   void Transform(const Datum&amp; datum, Dtype* transformed_data);
<span class="lineNum">     142 </span>            :   // Tranformation parameters
<span class="lineNum">     143 </span>            :   TransformationParameter param_;
<span class="lineNum">     144 </span>            : 
<span class="lineNum">     145 </span>            : 
<span class="lineNum">     146 </span>            :   shared_ptr&lt;Caffe::RNG&gt; rng_;
<span class="lineNum">     147 </span>            :   Phase phase_;
<span class="lineNum">     148 </span>            :   Blob&lt;Dtype&gt; data_mean_;
<span class="lineNum">     149 </span>            :   vector&lt;Dtype&gt; mean_values_;
<span class="lineNum">     150 </span>            : };
<span class="lineNum">     151 </span>            : 
<span class="lineNum">     152 </span>            : }  // namespace caffe
<span class="lineNum">     153 </span>            : 
<span class="lineNum">     154 </span>            : #endif  // CAFFE_DATA_TRANSFORMER_HPP_
</pre>
      </td>
    </tr>
  </table>
  <br>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
    <tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LCOV version 1.12</a></td></tr>
  </table>
  <br>

</body>
</html>
